﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using StyleMVVM.Data.Activation;
using StyleMVVM.DependencyInjection;
using Windows.Data.Xml.Dom;
using Windows.UI.Notifications;

namespace StyleMVVM.Notification.Toast
{
	public sealed class ToastService : IToastService, IActivationAware
	{
		private ToastNotifier notifier;

		public static void RegisterExport(IDependencyInjectionContainer container)
		{
			container.Register(typeof(ToastService)).As(typeof(IToastService)).AndSharedPermenantly();
		}

		public IToastText01 CreateToastText01()
		{
			return new ToastText01();
		}

		public IToastText02 CreateToastText02()
		{
			return new ToastText02();
		}

		public IToastText03 CreateToastText03()
		{
			return new ToastText03();
		}

		public IToastText04 CreateToastText04()
		{
			return new ToastText04();
		}

		public IToastImageAndText01 CreateoastImageAndText01()
		{
			return new ToastImageAndText01();
		}

		public IToastImageAndText02 CreateoastImageAndText02()
		{
			return new ToastImageAndText02();
		}

		public IToastImageAndText03 CreateoastImageAndText03()
		{
			return new ToastImageAndText03();
		}

		public IToastImageAndText04 CreateoastImageAndText04()
		{
			return new ToastImageAndText04();
		}

		public void Toast(IToastNotification toast)
		{
			XmlDocument document = new XmlDocument();
			document.LoadXml(toast.GenerateXML());

			ToastNotification newNotification = new ToastNotification(document);

			notifier.Show(newNotification);
		}

		public void Activate()
		{
			notifier = ToastNotificationManager.CreateToastNotifier();
		}
	}
}